package com.controller.backend;

import com.biz.BdUserinfoBiz;
import com.controller.backend.BaseController;
import com.core.Result;
import com.core.ResultGenerator;
import com.entity.model.BdTeam;
import com.entity.model.BdUserinfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Condition;

import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * Created by jc on 2020/01/06.
 */
@Controller
@RequestMapping("/backend/security/bdUserinfo")
public class BdUserinfoController extends BaseController<BdUserinfo> {
    @Autowired
    private BdUserinfoBiz bdUserinfoBiz;


    @RequestMapping(value = "getAccount", method = RequestMethod.POST)
    @ResponseBody
    public Result getAccount(Integer bdTeamId) throws Exception {
        if (bdTeamId == null) {
            return ResultGenerator.genFailResult("系统异常");
        }

        Condition cond = new Condition(BdUserinfo.class);
        cond.createCriteria().andEqualTo("bdTeamId", bdTeamId).andEqualTo("isSuper", 1);
        List<BdUserinfo> list = bdUserinfoBiz.findByCondition(cond);
        if (list.size() > 0) {
            return ResultGenerator.genSuccessResult(list.get(0));
        }
        return ResultGenerator.genSuccessResult();
    }
}
